package com.jdk.learn.juc2.thread;

/**
 * 类功能描述:
 *      ThreadLocal不可继承  父子线程问题
 * @author bgt
 * @version V1.0
 * @since 2019-02-01 10:31
 */
public class ThreadLocalDemo {
    private static ThreadLocal<String> threadLocal=new ThreadLocal<>();

    static void print(String str){
        System.out.println(str+":"+threadLocal.get());

        threadLocal.remove();
    }

    public static void main(String[] args) {
        Thread one=new Thread(()->{
            threadLocal.set("one value");
            print("one");
            System.out.println("one get:"+threadLocal.get());
        });
        Thread two=new Thread(()->{
            threadLocal.set("two value");
            print("two");
            System.out.println("two get:"+threadLocal.get());
        });
        one.start();
        two.start();

    }
}
